package com.atguigu.lease.common.sms;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
* aliyun的配置类
* */
@Configuration
public class AliyunSmsConfiguration {

    @Autowired
    AliyunSMSProperties properties;
    @Bean
    public Client client(){

        try {
            //配置信息
            Config config=new Config();
            config.setAccessKeyId(properties.getAccessKeyId());
            config.setAccessKeySecret(properties.getAccessKeySecret());
            config.setEndpoint(properties.getEndpoint());

            //短信客户端API
            Client client=new Client(config);
            return  client;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
